package com.job.service.impl;

import com.job.dao.JobDao;
import com.job.pojo.JobInfo;
import com.job.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Surpass
 * @Package com.job.service.impl
 * @Description: ${todo}
 * @date 2020/4/30 16:17
 */
@Service
public class JobServiceImpl implements JobService {

    @Autowired
    private JobDao jobDao;

    @Transactional
    @Override
    public void save(JobInfo jobInfo) {


        List<JobInfo> list = this.list(jobInfo);

        if (list.size()==0){
            this.jobDao.saveAndFlush(jobInfo);
        }
    }

    @Override
    public List<JobInfo> list(JobInfo jobInfo) {
        //设置查询条件
        Example example = Example.of(jobInfo);

        return this.jobDao.findAll(example);

    }
}
